package com.example.handsets8app.Customer;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.handsets8app.R;


public class CheckTip extends RelativeLayout {

    private ImageView mtipIco;
    private TextView mtipText;

    public CheckTip(Context context) {
        this(context, null);
    }

    public CheckTip(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public CheckTip(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context, attrs);
    }

    private void initView(Context context, AttributeSet attrs) {
        LayoutInflater.from(context).inflate(R.layout.check_tip, this, true);
        mtipIco = (ImageView) findViewById(R.id.iv_tip_ico);
        mtipText = (TextView) findViewById(R.id.tv_tip_text);

        TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.CheckTip);
        if (attributes != null) {
            int tipIco = attributes.getResourceId(R.styleable.CheckTip_tip_ico, R.drawable.ic_launcher_background);

            mtipIco.setBackgroundResource(tipIco);

            String tipText = attributes.getString(R.styleable.CheckTip_tip_text);
            mtipText.setText(tipText);

            int tipColor = attributes.getColor(R.styleable.CheckTip_tip_color, Color.RED);
            mtipText.setTextColor(tipColor);

        }
        attributes.recycle();
    }

    public void SetIcoBg(int id) {
        mtipIco.setBackgroundResource(id);
    }

    public void SetText(int color, String ss) {
        mtipText.setText(ss);
        mtipText.setTextColor(getResources().getColor(color));
    }
}
